Skip to content

fix: upload file style#2953

Merged
wangdan-fit2cloud merged 1 commit intomainfrom
pr@main/upload-file
Apr 22, 2025
Merged

fix: upload file style#2953
wangdan-fit2cloud merged 1 commit intomainfrom
pr@main/upload-file

Conversation

@wangdan-fit2cloud
Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

Summary of your change

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Apr 22, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Apr 22, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wangdan-fit2cloud wangdan-fit2cloud merged commit 77e9662 into main Apr 22, 2025
4 of 5 checks passed
@wangdan-fit2cloud wangdan-fit2cloud deleted the pr@main/upload-file branch April 22, 2025 09:31
.file-image {
position: relative;
overflow: inherit;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few issues and suggestions to improve the provided code:

  1. Duplicate Code: The repeated code block for <template v-for...> can be refactored into a single component. This will make the code cleaner and more maintainable.

  2. Flexbox Layout Improvements:

    • class="flex-between" should be replaced with flex: space-between or similar properties that control equal spacing between elements.
    • You might want to adjust padding or margin styles to ensure better alignment of text within the flex container.
  3. Responsive Design:

    • Ensure that width="24" is responsive if the card or images need to scale down based on window size or other factors.
  4. Icon Styles:

    • There's an issue with the icon style in the delete button where the vertical positioning isn't consistent across different browsers (e.g., Firefox).
      Consider updating the CSS class used for the icons.
  5. Consistent Class Names:

    • Use .color-secondary consistently across all color definitions, e.g., .primary-color, .error-color.
      Also, consider using standard class names like .delete-button instead of custom ones.
  6. Optimization Suggestions:

    • If loading times become problematic due to heavy image processing, consider optimizing image quality during uploads or loading from a CDN.
      Implement lazy loading techniques if possible to reduce initial load time, but be cautious not to sacrifice responsiveness too much.

Here’s a simplified version of how some parts of the code could be improved:

Revised Code Snippet

<!-- Refactored template snippet -->
<template v-for="(item, index) in fileList" :key="index">
  <el-card shadow="never" style="--el-card-padding: 8px" class="file cursor">
    <div
      class="file-content flex-between align-center"
      @mouseenter.stop="mouseenter(item)"
      @mouseleave.stop="mouseleave()"
    >
      <div>
        <img :src="getImgUrl(item.name)" alt="" width="24" />
        <span class="ml-4 ellipsis-1">{{ item.name }}</span>
      </div>
      <button @click="deleteFile(index)" class="delete-button color-secondary">
        <circle-close-filled></circle-close-filled>
      </button>
    </div>
  </el-card>
</template>

<style scoped>
.file-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.delete-button {
  background-color: transparent;
  border:none;
  outline: none;
}
</style>

<script setup>
import { CircleCloseFilled } from '@element-plus/icons-vue';
// Other components & logic imports

const fileList = reactive([
  // Your list items here
]);

const getImgUrl = (name) => {
  return `/path/to/images/${encodeURIComponent(name)}.png`;
};
</script>

This revision reduces redundancy by extracting common content and behavior into separate classes, making it easier to maintain and understand.

<img class="mr-12" :width="32" src="@/assets/fileType/unknown-icon.svg" alt="" />
<div>
<p class="line-height-22 mt-4">
{{ $t('common.fileUpload.other') }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code snippet suggests two changes that could potentially improve efficiency and clarity:

  1. Consistent Use of v-bind: The line that modifies the width attribute is using single quotes ('), whereas others use double quotes ("). It's good practice to ensure consistency in template syntax, especially when including variables inside double quotes.

  2. Code Readability:

        >
          >
            <div class="flex-between">
              <div class="flex align-center">
    
  •          <img class="mr-12" src="@/assets/icon_file-doc.svg" alt="" />
    
  •          <!-- Add necessary space padding here -->
             <div style="padding-right: 1rem;">
    

Adding some space padding (e.g., a margin or padding) to the `.div` element can improve its readability and make it visually distinct from neighboring elements.

These minor improvements aim to enhance coding standards and maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants